package com.atomy.bigeventsservice.controller;

import com.atomy.bigeventsservice.entity.Category;
import com.atomy.bigeventsservice.entity.Result;
import com.atomy.bigeventsservice.service.CategoryServer;
import com.atomy.bigeventsservice.utils.JwtUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

@Slf4j
@RestController
@RequestMapping("/category")
public class CategoryController {
    @Autowired
    private CategoryServer categoryServer;
    @GetMapping()
    public Result getCategory(@RequestHeader("token") String token){
        Map<String,Object> map= JwtUtils.parseJWT(token);
        List<Category> arrayList=categoryServer.getCategoryById((Integer)map.get("id"));
        return Result.success(arrayList);
    }
}
